package com.pan.test.socket.example05;

import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

public class Client05 {

    public static String PATH = System.getProperty("user.dir")+"\\picture\\client";

    public static void main(String[] args) throws IOException {
        Socket socket = new Socket(InetAddress.getByName("192.168.31.43"),11452);

        OutputStream outputStream = socket.getOutputStream();
        String fileName = "听雨";
        outputStream.write(fileName.getBytes());
        socket.shutdownOutput();

        InputStream inputStream = socket.getInputStream();
        File file = new File(PATH+"\\receive.m4a");
        file.createNewFile();
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        fileOutputStream.write(inputStream.readAllBytes());


        fileOutputStream.close();
        inputStream.close();
        outputStream.close();
        socket.close();
    }
}
